package ac.github.os.internal.core.trigger

import ac.github.os.internal.core.config.StringConfig
import ac.github.os.internal.core.config.get
import org.bukkit.Location
import taboolib.common5.Coerce

open class LocationTrigger(
    val location: Location
) : Trigger

fun Location.dynamic(config: StringConfig) : Location {
    val location = offset(config)
    config.get<Double>("mult")?.let { location.multiply(it) }
    return location
}

fun Location.offset(config: StringConfig) : Location {
    val list = config.get("offset", listOf("0.0", "0.0", "0.0"))!!.map { Coerce.toDouble(it) }
    return this.clone().add(list[0],list[1],list[2])
}